/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package com.maschinenstuermer.profiler.trace.impl;

import com.maschinenstuermer.profiler.trace.Metrics;
import com.maschinenstuermer.profiler.trace.TracePackage;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Metrics</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link com.maschinenstuermer.profiler.trace.impl.MetricsImpl#getCalls <em>Calls</em>}</li>
 *   <li>{@link com.maschinenstuermer.profiler.trace.impl.MetricsImpl#getMaxTimeNs <em>Max Time Ns</em>}</li>
 *   <li>{@link com.maschinenstuermer.profiler.trace.impl.MetricsImpl#getMinTimeNs <em>Min Time Ns</em>}</li>
 *   <li>{@link com.maschinenstuermer.profiler.trace.impl.MetricsImpl#getTotalTimeNs <em>Total Time Ns</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class MetricsImpl extends EObjectImpl implements Metrics {
	/**
	 * The default value of the '{@link #getCalls() <em>Calls</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getCalls()
	 * @generated
	 * @ordered
	 */
	protected static final int CALLS_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getCalls() <em>Calls</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getCalls()
	 * @generated
	 * @ordered
	 */
	protected int calls = CALLS_EDEFAULT;

	/**
	 * This is true if the Calls attribute has been set.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 * @ordered
	 */
	protected boolean callsESet;

	/**
	 * The default value of the '{@link #getMaxTimeNs() <em>Max Time Ns</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMaxTimeNs()
	 * @generated
	 * @ordered
	 */
	protected static final long MAX_TIME_NS_EDEFAULT = 0L;

	/**
	 * The cached value of the '{@link #getMaxTimeNs() <em>Max Time Ns</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMaxTimeNs()
	 * @generated
	 * @ordered
	 */
	protected long maxTimeNs = MAX_TIME_NS_EDEFAULT;

	/**
	 * This is true if the Max Time Ns attribute has been set.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 * @ordered
	 */
	protected boolean maxTimeNsESet;

	/**
	 * The default value of the '{@link #getMinTimeNs() <em>Min Time Ns</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMinTimeNs()
	 * @generated
	 * @ordered
	 */
	protected static final long MIN_TIME_NS_EDEFAULT = 0L;

	/**
	 * The cached value of the '{@link #getMinTimeNs() <em>Min Time Ns</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMinTimeNs()
	 * @generated
	 * @ordered
	 */
	protected long minTimeNs = MIN_TIME_NS_EDEFAULT;

	/**
	 * This is true if the Min Time Ns attribute has been set.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 * @ordered
	 */
	protected boolean minTimeNsESet;

	/**
	 * The default value of the '{@link #getTotalTimeNs() <em>Total Time Ns</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getTotalTimeNs()
	 * @generated
	 * @ordered
	 */
	protected static final long TOTAL_TIME_NS_EDEFAULT = 0L;

	/**
	 * The cached value of the '{@link #getTotalTimeNs() <em>Total Time Ns</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getTotalTimeNs()
	 * @generated
	 * @ordered
	 */
	protected long totalTimeNs = TOTAL_TIME_NS_EDEFAULT;

	/**
	 * This is true if the Total Time Ns attribute has been set.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 * @ordered
	 */
	protected boolean totalTimeNsESet;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected MetricsImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return TracePackage.Literals.METRICS;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getCalls() {
		return calls;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setCalls(int newCalls) {
		int oldCalls = calls;
		calls = newCalls;
		boolean oldCallsESet = callsESet;
		callsESet = true;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, TracePackage.METRICS__CALLS, oldCalls, calls, !oldCallsESet));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void unsetCalls() {
		int oldCalls = calls;
		boolean oldCallsESet = callsESet;
		calls = CALLS_EDEFAULT;
		callsESet = false;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.UNSET, TracePackage.METRICS__CALLS, oldCalls, CALLS_EDEFAULT, oldCallsESet));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean isSetCalls() {
		return callsESet;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public long getMaxTimeNs() {
		return maxTimeNs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setMaxTimeNs(long newMaxTimeNs) {
		long oldMaxTimeNs = maxTimeNs;
		maxTimeNs = newMaxTimeNs;
		boolean oldMaxTimeNsESet = maxTimeNsESet;
		maxTimeNsESet = true;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, TracePackage.METRICS__MAX_TIME_NS, oldMaxTimeNs, maxTimeNs, !oldMaxTimeNsESet));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void unsetMaxTimeNs() {
		long oldMaxTimeNs = maxTimeNs;
		boolean oldMaxTimeNsESet = maxTimeNsESet;
		maxTimeNs = MAX_TIME_NS_EDEFAULT;
		maxTimeNsESet = false;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.UNSET, TracePackage.METRICS__MAX_TIME_NS, oldMaxTimeNs, MAX_TIME_NS_EDEFAULT, oldMaxTimeNsESet));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean isSetMaxTimeNs() {
		return maxTimeNsESet;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public long getMinTimeNs() {
		return minTimeNs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setMinTimeNs(long newMinTimeNs) {
		long oldMinTimeNs = minTimeNs;
		minTimeNs = newMinTimeNs;
		boolean oldMinTimeNsESet = minTimeNsESet;
		minTimeNsESet = true;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, TracePackage.METRICS__MIN_TIME_NS, oldMinTimeNs, minTimeNs, !oldMinTimeNsESet));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void unsetMinTimeNs() {
		long oldMinTimeNs = minTimeNs;
		boolean oldMinTimeNsESet = minTimeNsESet;
		minTimeNs = MIN_TIME_NS_EDEFAULT;
		minTimeNsESet = false;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.UNSET, TracePackage.METRICS__MIN_TIME_NS, oldMinTimeNs, MIN_TIME_NS_EDEFAULT, oldMinTimeNsESet));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean isSetMinTimeNs() {
		return minTimeNsESet;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public long getTotalTimeNs() {
		return totalTimeNs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setTotalTimeNs(long newTotalTimeNs) {
		long oldTotalTimeNs = totalTimeNs;
		totalTimeNs = newTotalTimeNs;
		boolean oldTotalTimeNsESet = totalTimeNsESet;
		totalTimeNsESet = true;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, TracePackage.METRICS__TOTAL_TIME_NS, oldTotalTimeNs, totalTimeNs, !oldTotalTimeNsESet));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void unsetTotalTimeNs() {
		long oldTotalTimeNs = totalTimeNs;
		boolean oldTotalTimeNsESet = totalTimeNsESet;
		totalTimeNs = TOTAL_TIME_NS_EDEFAULT;
		totalTimeNsESet = false;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.UNSET, TracePackage.METRICS__TOTAL_TIME_NS, oldTotalTimeNs, TOTAL_TIME_NS_EDEFAULT, oldTotalTimeNsESet));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean isSetTotalTimeNs() {
		return totalTimeNsESet;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case TracePackage.METRICS__CALLS:
				return new Integer(getCalls());
			case TracePackage.METRICS__MAX_TIME_NS:
				return new Long(getMaxTimeNs());
			case TracePackage.METRICS__MIN_TIME_NS:
				return new Long(getMinTimeNs());
			case TracePackage.METRICS__TOTAL_TIME_NS:
				return new Long(getTotalTimeNs());
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case TracePackage.METRICS__CALLS:
				setCalls(((Integer)newValue).intValue());
				return;
			case TracePackage.METRICS__MAX_TIME_NS:
				setMaxTimeNs(((Long)newValue).longValue());
				return;
			case TracePackage.METRICS__MIN_TIME_NS:
				setMinTimeNs(((Long)newValue).longValue());
				return;
			case TracePackage.METRICS__TOTAL_TIME_NS:
				setTotalTimeNs(((Long)newValue).longValue());
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case TracePackage.METRICS__CALLS:
				unsetCalls();
				return;
			case TracePackage.METRICS__MAX_TIME_NS:
				unsetMaxTimeNs();
				return;
			case TracePackage.METRICS__MIN_TIME_NS:
				unsetMinTimeNs();
				return;
			case TracePackage.METRICS__TOTAL_TIME_NS:
				unsetTotalTimeNs();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case TracePackage.METRICS__CALLS:
				return isSetCalls();
			case TracePackage.METRICS__MAX_TIME_NS:
				return isSetMaxTimeNs();
			case TracePackage.METRICS__MIN_TIME_NS:
				return isSetMinTimeNs();
			case TracePackage.METRICS__TOTAL_TIME_NS:
				return isSetTotalTimeNs();
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (calls: ");
		if (callsESet) result.append(calls); else result.append("<unset>");
		result.append(", maxTimeNs: ");
		if (maxTimeNsESet) result.append(maxTimeNs); else result.append("<unset>");
		result.append(", minTimeNs: ");
		if (minTimeNsESet) result.append(minTimeNs); else result.append("<unset>");
		result.append(", totalTimeNs: ");
		if (totalTimeNsESet) result.append(totalTimeNs); else result.append("<unset>");
		result.append(')');
		return result.toString();
	}

} //MetricsImpl
